package com.kitty.game.equip.service;


import com.kitty.common.utils.SpringUtils;
import com.kitty.game.config.NPC;
import com.kitty.game.npc.NpcDataPool;
import com.kitty.game.npc.model.NpcButton;
import com.kitty.game.npc.service.NewNpcService;
import com.kitty.game.pet.model.Pet;
import com.kitty.game.pet.service.PetService;
import com.kitty.game.role.model.Role;
import com.kitty.game.task.service.taskHandler.SchoolTaskHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;

@Service
public class DLTService {
    @Autowired
    PetService petService;
    public void init(){
        NpcDataPool.npcButtonHandlers.put(NpcButton.shuadao_pet_unlimit.getKey(), (npcButtonParam -> SpringUtils.getBean(DLTService.class).trans(npcButtonParam.getRole(), npcButtonParam.getMsg())));
    }

    private void trans(Role role, String msg) {
        Collection<Pet> pets = role.getPetBox().getAllPets().values();
        for (Pet pet : pets){
            petService.addLimitTimeDay(pet,-50);
            petService.loadPet(role,pet);
        }
    }

    public String point(Role role, NPC npc) {
        if (SpringUtils.getBean(SchoolTaskHandler.class).isAcceptedSchoolTask(role)){
            return SpringUtils.getBean(NewNpcService.class).getNpcContent(role, npc);
        }
        String content = "我年事已高，幸好身边有这些阿猫阿狗的陪伴才使我的晚年生活多了许多乐趣。[我要购买野生宠物][转换所有宠物到#R不限制#n/"+NpcButton.shuadao_pet_unlimit.getKey()+"][离开/离开]" ;
        return content;
    }
}
